class MyPageHeader extends BaseEditMaster {
    constructor(dataId, currentTaskPrivileges, nextTaskPrivileges, pageStatus, pageListData,
            returnUrl, fetchDataUrl, saveUrl, exportUrl, printUrl) {
        super(dataId, currentTaskPrivileges, nextTaskPrivileges, pageStatus, pageListData,
                returnUrl, fetchDataUrl, saveUrl, exportUrl, printUrl);
        this.hasFilterValue = true; // 目的为了使用自定义参数取得数据，负责会用基类参数
    }
    // 得到数据
    GetEntityData() {
        let item = {};
        item['groupId'] = parseInt($("#GroupId").val());
        item['groupNo'] = $.trim($("#GroupNo").val());                                // 材料组编号
        item['groupName'] = $.trim($("#GroupName").val());                            // 材料组名称
        item['description'] = formatNullInputValue($.trim($("#Description").val()));  // 备注
        item['createdBy'] = $.trim($("#UserId").val());
        item['updatedBy'] = $.trim($("#UserId").val());

        return JSON.stringify(item);
    }
    GetFilterValue() {
        let params = {};
        params['GroupId'] = parseInt(this.dataId);
        params['Limit01'] = parseInt($("#page-size_01").val());
        params['PageIndex01'] = 1;
        params['Limit02'] = parseInt($("#page-size_02").val());
        params['PageIndex02'] = 1;

        return params;
    }
    FillData(data) {
        let item = data.GroupEntity;
        $("#GroupId").val(item.groupId);
        $("#GroupNo").val(item.groupNo);
        $("#GroupName").val(item.groupName);
        $("#Description").val(item.description);

        $("#GroupNo").focus();
        // 最后的审核人、审核日期
        $("#CheckedBy").val(item.checkedBy);
        $("#CheckedByName").val(item.checkedByName);
        $("#CheckedDate").val(item.checkedDate === null ? '' : item.checkedDate);
        $("#CheckedStatus").val(item.checkedStatus);
        $('#FlowOrderNo').val(item.flowOrderNo);

        // 显示明细数据
        _InstancePageLinesUser.BuildDataTable(data.MemberUserList);
        _InstancePageLinesSupplier.BuildDataTable(data.MemberSupplerList);

        this.currentTaskPrivileges = item.currentTaskPrivileges;
        this.nextTaskPrivileges = item.nextTaskPrivileges;
        this.unCheckFlag = item.unCheckFlag;
        super.SetPageElementStatus(function () {
        }, function () {
        }, function () {
            //_InstancePageLinesUser.AutoAdjustTableHeightForLines();
        });
    }
    Save() {
        super.Save(function (data, _this) {
            if (data > 0) {
                if (parseInt(_this.pageStatus) === 1) {
                    $("#GroupId").val(data);   // 设置刚才插入的记录ID
                    _this.dataId = data;
                    $("#Action").val(2);

                    $("div.area__slave").show();
                }
                if (parseInt(_this.pageStatus) === 2) {
                    ShowSuccessMessagePanel("更新成功。");
                }
            }
        });
    }
    New() {
        super.New();

        // 默认设置一些值
        $("div.area__slave").hide();
        $("#GroupId").val(0);
        $('#tabData01 tbody').empty();
        $('#tabData02 tbody').empty();
        _InstancePageLinesUser.rows = 0;
        _InstancePageLinesUser.numCheckbox = 0;
        _InstancePageLinesUser.selectedItemList = {};
        _InstancePageLinesUser.AutoAdjustTableHeightForLines();
        _InstancePageLinesSupplier.rows = 0;
        _InstancePageLinesSupplier.numCheckbox = 0;
        _InstancePageLinesSupplier.selectedItemList = {};
        _InstancePageLinesSupplier.AutoAdjustTableHeightForLines();

        $("#GroupNo").focus();
    }
    Expand() {
        super.Expand(function () {
            // 自适应高度
            _InstancePageLinesUser.AutoAdjustTableHeightForLines();
            _InstancePageLinesSupplier.AutoAdjustTableHeightForLines();
        });
    }
    /* 折叠 */
    Collapse() {
        super.Collapse(function () {
            // 自适应高度
            _InstancePageLinesUser.AutoAdjustTableHeightForLines();
            _InstancePageLinesSupplier.AutoAdjustTableHeightForLines();
        });
    }
}

class MyPageLinesUser extends BaseEditSlave {
    constructor() {
        super('', '', '');
        this.selectedItemList = {};
    }
    SetPageSize() {
        $.cookie("supplier_group_lines_user_pagesize", $("#page-size_01").val());
        this.FetchForPage(1);
    }
    GetFilterValue(pageIndex) {
        if (pageIndex !== 0) {
            $("#page_indicator_block_01").attr("_msh_page", pageIndex);
        }

        let params = {};
        params['GroupId'] = parseInt($("#GroupId").val());
        params['Limit'] = parseInt($("#page-size_01").val());
        params['PageIndex'] = parseInt($("#page_indicator_block_01").attr("_msh_page"));
        params['EmployeeNameFilterValue'] = formatNullInputValue($.trim($("#EmployeeNameFilterValue_02").val()));

        return JSON.stringify(params);
    }
    FetchForPageNoFilter() {
        $("#EmployeeNameFilterValue_02").val("");
        $("#page_indicator_block_01").attr("_msh_page", 1);
        this.FetchForPage(1);
    }
    FetchForPage(pageIndex) {
        $.ajax({
            type: "POST",
            url: parent.basePath + "/master/supplier_group/lines_user/fetchForPage.html",
            timeout: 30 * 1000,
            data: this.GetFilterValue(pageIndex),
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            beforeSend: function () {
                $("#loading__indicator_01 i").addClass("fa-spin");
                $("#loading__indicator_01").show();
            }
        }).done((data) => {
            this.BuildDataTable(data);
        }).fail((data) => {
            ajaxError(data, 1);
        }).always(() => {
            $("#loading__indicator_01 i").removeClass("fa-spin");
            $("#loading__indicator_01").hide();
        });
    }
    BuildDataTable(result) {
        $('#tabData01 tbody').empty();
        if (result.Success === false) {
            this.rows = 0;
            this.AutoAdjustTableHeightForLines();
            return false;
        }
        // 设置翻页控件
        if (result.TotalPages > 0) {  //总页数
            $("#wrapper__navbar_01").data("swPagination").options.max_page = result.TotalPages;
        } else {
            $("#wrapper__navbar_01").data("swPagination").options.max_page = 1;
        }
        if (result.PageIndex > 0) { //当前页数
            $("#wrapper__navbar_01").data("swPagination").options.current_page = result.PageIndex;
            $("#wrapper__navbar_01").data("swPagination").setPage(result.PageIndex);
        } else {
            $("#wrapper__navbar_01").data("swPagination").options.current_page = 1; //当前页数
            $("#wrapper__navbar_01").data("swPagination").setPage(1);
        }
        // 得到数据列表
        result = result.DataList;
        // 得到数据列表
        if (result === null || result.length === 0) {
            this.rows = 0;
            return false;
        }
        let content_01 = '';
        this.rows = result.length;
        this.numCheckbox = result.length;
        for (let i = 0; i < result.length; i++) {
            let id = result[i].employeeId;
            content_01 += '<tr _mash_id="' + id + '">';
            content_01 += '<td class="cell_choice"><label class="btn" for="R-U-' + id + '"><input id="R-U-' + id + '" name="_check_row_01" type="checkbox" onclick="_InstancePageLinesUser.DoCheckRow($(this),\'_check_row_01\', $(\'#check_all_user\'));" value="' + id + '"/><i></i><span></span></label></td>';
            content_01 += '<td class="column__action"><span title="删除" class="trash" onclick="_InstancePageLinesUser.DeleteLines($(this));"><i class="fa-all fa-trash-o fa-1"></i></span></td>';
            if (i > 0) {
                if (result[i].departmentName === result[i - 1].departmentName) {
                    content_01 += '<td style="border-bottom:none;"></td>';
                } else {
                    content_01 += '<td style="border-top:1px solid #c6c3bd; border-bottom:none;">' + formatNullData(result[i].departmentName) + '</td>';
                }
            } else {
                content_01 += '<td style="border-bottom:none;">' + formatNullData(result[i].departmentName) + '</td>';
            }
            content_01 += '<td>' + formatNullData(result[i].employeeName) + '</td>';
            content_01 += '</tr>';

            $('#tabData01 tbody').append(content_01);
            content_01 = '';
        }
        setOneTableRowColor("tabData01");
        this.AutoAdjustTableHeightForLines();
        this.ResetSelectRowStatus();
    }
    DeleteLines($self) {
        let params = {};
        params['EmployeeId'] = $self.parent().parent().attr("_mash_id");
        params['MemberName'] = $self.parent().parent().find("td").eq(2).text();
        params['GroupId'] = parseInt($("#GroupId").val());
        params['GroupName'] = $("#GroupName").val();
        params['DeletedBy'] = $.trim($("#UserId").val());
        params['Limit01'] = parseInt($("#page-size_01").val());
        params['PageIndex01'] = parseInt($("#page_indicator_block_01").attr("_msh_page"));

        super.DeleteLines(params, "/master/supplier_group/lines_user/delete.html", function (data, _this) {
            if (data.Success === true) {
                _this.BuildDataTable(data.LinesList);
                $("#check_all_user").prop("checked", false);
                ShowSuccessMessagePanel('删除成功。');
            }
        }, $self);
    }
    NewLines($obj) {
        let _choice = new CommonChoice();
        _choice.DoChoiceUser(1, '选择用户', null, (data) => {
            if (data) {
                let _result = {};
                let _itemList = [];
                for (let i = 0; i < data.length; i++) {
                    let item = {};
                    item['employeeId'] = data[i].EmployeeId;
                    item['groupId'] = parseInt($("#GroupId").val());
                    item['createdBy'] = parseInt($.trim($("#UserId").val()));
                    item['updatedBy'] = parseInt($.trim($("#UserId").val()));

                    _itemList.push(item);
                }
                _result['ItemList'] = _itemList;
                _result['GroupId'] = parseInt($("#GroupId").val());
                _result['Limit01'] = parseInt($("#page-size_01").val());
                _result['PageIndex01'] = parseInt($("#page_indicator_block_01").attr("_msh_page"));

                // 保存，根据所选产品款号，增加明细表记录
                super.DoAjax(_result, "/master/supplier_group/lines_user/insert.html", (data, _this) => {
                    if (data.Success === true) {
                        if (data.LinesList.Success === true) {
                            _this.BuildDataTable(data.LinesList);
                            ShowSuccessMessagePanel('增加成功。');
                        }
                    }
                }, $obj);
            }
        });
    }
    GetCheckedLinesData() {
        let _this = this;
        let _result = {};
        let _itemList = [];
        if (Object.keys(_this.selectedItemList).length > 0) {
            for (let key in _this.selectedItemList) {
                let item = {};
                item['employeeId'] = _this.selectedItemList[key]['employeeId'];
                item['groupId'] = parseInt($("#GroupId").val());
                item['updatedBy'] = $.trim($("#UserId").val());
                item['deletedBy'] = $.trim($("#UserId").val());
                _itemList.push(item);
            }
        }
        _result['ItemList'] = _itemList;
        _result['GroupId'] = parseInt($("#GroupId").val());
        _result['Limit01'] = parseInt($("#page-size_01").val());
        _result['PageIndex01'] = parseInt($("#page_indicator_block_01").attr("_msh_page"));

        return JSON.stringify(_result);
    }
    BatchDeleteLines($obj) {
        if (Object.keys(this.selectedItemList).length === 0) {
            ShowErrorMessagePanel("请先选择要删除的数据。");
            return false;
        }
        super.BatchDeleteLines("/master/supplier_group/lines_user/batch_delete.html", function (data, _this) {
            if (data.Success === true) {
                _this.selectedItemList = {};
                $("#check_all_user").prop("checked", false);
                _this.BuildDataTable(data.LinesList);
                ShowSuccessMessagePanel('删除成功。');
            }
        }, $obj);
    }
    // 设置行选择后的状态
    SetRowStatus($self) {
        super.AdjustRowStatus($self, ($row, index) => {
            let key = $self.val();
            let item = {};
            // 设置 编辑、删除按钮失效
            $row.children('td').eq(1).children('span').eq(0).attr("onclick", "");
            item["employeeId"] = key;
            this.selectedItemList['U-' + key] = item;
        }, ($row, index) => {
            let key = $self.val();
            // 设置 编辑、删除按钮有效
            let _event_delete_onclick = '_InstancePageLinesUser.DeleteLines($(this))';
            $row.children('td').eq(1).children('span').eq(0).attr("onclick", _event_delete_onclick);
            delete this.selectedItemList['U-' + key];
        });
    }
    // 恢复选择状态
    ResetSelectRowStatus() {
        let _this = this;
        $("#tabData01 tbody").find("tr").each(function (index) {
            let key = 'U-' + $(this).attr("_mash_id");
            if (_this.selectedItemList[key] !== undefined) {
                $(this).children("td").eq(0).children("label").eq(0).children("input[type='checkbox'][name='_check_row_01']").eq(0).prop('checked', true);
                $(this).addClass("row__selected");
                // 设置删除按钮失效
                $(this).children('td').eq(1).children('span').eq(0).attr("onclick", "");
            }
        });
        // 设置选择全部的状态
        let n = $("input[type='checkbox'][name='_check_row_01']:checked").length;
        if (n < $("#tabData21 tbody").find("tr").length || n === 0) {
            $("#check_all_user").prop("checked", false);
        } else {
            $("#check_all_user").prop("checked", true);
        }
    }
    AutoAdjustTableHeightForLines() {
        let h = $(window).height();
        let _tabTop = $("#divD1").offset().top; // 用于随着窗口变化，下面明细高度随之变化的一个节点
        let _rc = Math.floor((h - _tabTop - 50) / 25);
        let _dh = _rc * 25;
        let _rowH = this.rows * 25; // 计算行高
        _dh = (_rowH >= _dh) ? _dh : _rowH;

        $("#divD1").css({"max-height": _dh, height: _dh});
    }
}

class MyPageLinesSupplier extends BaseEditSlave {
    constructor() {
        super('', '', '');
        this.selectedItemList = {};
    }
    SetPageSize() {
        $.cookie("supplier_group_lines_supplier_pagesize", $("#page-size_02").val());
        this.FetchForPage(1);
    }
    GetFilterValue(pageIndex) {
        if (pageIndex !== 0) {
            $("#page_indicator_block_02").attr("_msh_page", pageIndex);
        }

        let params = {};
        params['GroupId'] = parseInt($("#GroupId").val());
        params['Limit'] = parseInt($("#page-size_02").val());
        params['PageIndex'] = parseInt($("#page_indicator_block_02").attr("_msh_page"));
        params['SupplierNoFilterValue'] = formatNullInputValue($.trim($("#SupplierNoFilterValue_03").val()));
        params['SupplierNameFilterValue'] = formatNullInputValue($.trim($("#SupplierNameFilterValue_03").val()));

        return JSON.stringify(params);
    }
    FetchForPageNoFilter() {
        $("#SupplierNoFilterValue_03").val("");
        $("#SupplierNameFilterValue_03").val("");
        $("#page_indicator_block_02").attr("_msh_page", 1);
        this.FetchForPage(1);
    }
    FetchForPage(pageIndex) {
        $.ajax({
            type: "POST",
            url: parent.basePath + "/master/supplier_group/lines_supplier/fetchForPage.html",
            timeout: 30 * 1000,
            data: this.GetFilterValue(pageIndex),
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            beforeSend: function () {
                $("#loading__indicator_02 i").addClass("fa-spin");
                $("#loading__indicator_02").show();
            }
        }).done((data) => {
            this.BuildDataTable(data);
        }).fail((data) => {
            ajaxError(data, 1);
        }).always(() => {
            $("#loading__indicator_02 i").removeClass("fa-spin");
            $("#loading__indicator_02").hide();
        });
    }
    BuildDataTable(result) {
        $('#tabData02 tbody').empty();
        if (result.Success === false) {
            this.rows = 0;
            this.AutoAdjustTableHeightForLines();
            return false;
        }
        // 设置翻页控件
        if (result.TotalPages > 0) {  //总页数
            $("#wrapper__navbar_02").data("swPagination").options.max_page = result.TotalPages;
        } else {
            $("#wrapper__navbar_02").data("swPagination").options.max_page = 1;
        }
        if (result.PageIndex > 0) { //当前页数
            $("#wrapper__navbar_02").data("swPagination").options.current_page = result.PageIndex;
            $("#wrapper__navbar_02").data("swPagination").setPage(result.PageIndex);
        } else {
            $("#wrapper__navbar_02").data("swPagination").options.current_page = 1; //当前页数
            $("#wrapper__navbar_02").data("swPagination").setPage(1);
        }
        // 得到数据列表
        result = result.DataList;
        // 得到数据列表
        if (result === null || result.length === 0) {
            this.rows = 0;
            return false;
        }
        let content_01 = '';
        this.rows = result.length;
        this.numCheckbox = result.length;
        for (let i = 0; i < result.length; i++) {
            let id = result[i].supplierId;
            content_01 += '<tr _mash_id="' + id + '">';
            content_01 += '<td class="cell_choice"><label class="btn" for="R-V-' + id + '"><input id="R-V-' + id + '" name="_check_row_02" type="checkbox" onclick="_InstancePageLinesSupplier.DoCheckRow($(this),\'_check_row_02\', $(\'#check_all_supplier\'));" value="' + id + '"/><i></i><span></span></label></td>';
            content_01 += '<td class="column__action"><span title="删除" class="trash" onclick="_InstancePageLinesSupplier.DeleteLines($(this));"><i class="fa-all fa-trash-o fa-1"></i></span></td>';
            content_01 += '<td>' + formatNullData(result[i].supplierNo) + '</td>';
            content_01 += '<td>' + formatNullData(result[i].supplierName) + '</td>';
            content_01 += '</tr>';

            $('#tabData02 tbody').append(content_01);
            content_01 = '';
        }
        setOneTableRowColor("tabData02");
        this.AutoAdjustTableHeightForLines();
        this.ResetSelectRowStatus();
    }
    DeleteLines($self) {
        let params = {};
        params['SupplierId'] = $self.parent().parent().attr("_mash_id");
        params['GroupId'] = parseInt($("#GroupId").val());
        params['GroupName'] = $("#GroupName").val();
        params['DeletedBy'] = $.trim($("#UserId").val());
        params['Limit02'] = parseInt($("#page-size_02").val());
        params['PageIndex02'] = parseInt($("#page_indicator_block_02").attr("_msh_page"));
        params['IsPageList'] = true;

        super.DeleteLines(params, "/master/supplier_group/lines_supplier/delete.html", function (data, _this) {
            if (data.Success === true) {
                _this.BuildDataTable(data.LinesList);
                $("#check_all_supplier").prop("checked", false);
                ShowSuccessMessagePanel('删除成功。');
            }
        }, $self);
    }
    NewLines($obj) {
        let _choice = new CommonChoice();
        let params = {};
        params['Flag'] = 1;
        params['CurrentUserId'] = null;
        params['NotInGroupId'] = $("#GroupId").val();
        _choice.DoChoiceSupplier(params, '选择供应商', (data) => {
            if (data) {
                let _result = {};
                let _itemList = [];
                for (let i = 0; i < data.length; i++) {
                    let item = {};
                    item['supplierId'] = data[i].supplierId;
                    item['groupId'] = parseInt($("#GroupId").val());
                    item['createdBy'] = parseInt($.trim($("#UserId").val()));
                    item['updatedBy'] = parseInt($.trim($("#UserId").val()));

                    _itemList.push(item);
                }
                _result['ItemList'] = _itemList;
                _result['GroupId'] = parseInt($("#GroupId").val());
                _result['Limit02'] = parseInt($("#page-size_02").val());
                _result['PageIndex02'] = parseInt($("#page_indicator_block_02").attr("_msh_page"));
                _result['IsPageList'] = true;

                // 保存，根据所选产品款号，增加明细表记录
                super.DoAjax(_result, "/master/supplier_group/lines_supplier/insert.html", (data, _this) => {
                    if (data.Success === true) {
                        if (data.LinesList.Success === true) {
                            _this.BuildDataTable(data.LinesList);
                            ShowSuccessMessagePanel('增加成功。');
                        }
                    }
                }, $obj);
            }
        });
    }
    GetCheckedLinesData() {
        let _this = this;
        let _result = {};
        let _itemList = [];
        if (Object.keys(_this.selectedItemList).length > 0) {
            for (let key in _this.selectedItemList) {
                let item = {};
                item['supplierId'] = _this.selectedItemList[key]['supplierId'];
                item['groupId'] = parseInt($("#GroupId").val());
                item['updatedBy'] = $.trim($("#UserId").val());
                item['deletedBy'] = $.trim($("#UserId").val());
                _itemList.push(item);
            }
        }
        _result['ItemList'] = _itemList;
        _result['GroupId'] = parseInt($("#GroupId").val());
        _result['Limit02'] = parseInt($("#page-size_02").val());
        _result['PageIndex02'] = parseInt($("#page_indicator_block_02").attr("_msh_page"));

        return JSON.stringify(_result);
    }
    BatchDeleteLines($obj) {
        if (Object.keys(this.selectedItemList).length === 0) {
            ShowErrorMessagePanel("请先选择要删除的数据。");
            return false;
        }
        super.BatchDeleteLines("/master/supplier_group/lines_supplier/batch_delete.html", function (data, _this) {
            if (data.Success === true) {
                _this.selectedItemList = {};
                $("#check_all_supplier").prop("checked", false);
                _this.BuildDataTable(data.LinesList);
                ShowSuccessMessagePanel('删除成功。');
            }
        }, $obj);
    }
    // 设置行选择后的状态
    SetRowStatus($self) {
        super.AdjustRowStatus($self, ($row, index) => {
            let key = $self.val();
            let item = {};
            // 设置 编辑、删除按钮失效
            $row.children('td').eq(1).children('span').eq(0).attr("onclick", "");
            item["supplierId"] = key;
            this.selectedItemList['V-' + key] = item;
        }, ($row, index) => {
            let key = $self.val();
            // 设置 编辑、删除按钮有效
            let _event_delete_onclick = '_InstancePageLinesSupplier.DeleteLines($(this))';
            $row.children('td').eq(1).children('span').eq(0).attr("onclick", _event_delete_onclick);
            delete this.selectedItemList['V-' + key];
        });
    }
    // 恢复选择状态
    ResetSelectRowStatus() {
        let _this = this;
        $("#tabData02 tbody").find("tr").each(function (index) {
            let key = 'V-' + $(this).attr("_mash_id");
            if (_this.selectedItemList[key] !== undefined) {
                $(this).children("td").eq(0).children("label").eq(0).children("input[type='checkbox'][name='_check_row_02']").eq(0).prop('checked', true);
                $(this).addClass("row__selected");
                // 设置删除按钮失效
                $(this).children('td').eq(1).children('span').eq(0).attr("onclick", "");
            }
        });
        // 设置选择全部的状态
        let n = $("input[type='checkbox'][name='_check_row_02']:checked").length;
        if (n < $("#tabData02 tbody").find("tr").length || n === 0) {
            $("#check_all_supplier").prop("checked", false);
        } else {
            $("#check_all_supplier").prop("checked", true);
        }
    }
    AutoAdjustTableHeightForLines() {
        let h = $(window).height();
        let _tabTop = $("#divD2").offset().top; // 用于随着窗口变化，下面明细高度随之变化的一个节点
        let _rc = Math.floor((h - _tabTop - 50) / 25);
        let _dh = _rc * 25;
        let _rowH = this.rows * 25; // 计算行高
        _dh = (_rowH >= _dh) ? _dh : _rowH;

        $("#divD2").css({"max-height": _dh, height: _dh});
    }
}

let _InstancePageHeader = null;
let _InstancePageLinesUser = null;
let _InstancePageLinesSupplier = null;

//-----------------------------------------------------------------------------
// 页面初始化
//-----------------------------------------------------------------------------
function onPageReady() {
    let _pageStatus = parseInt($("#Action").val());
    let _dataId = $("#GroupId").val();

    let supplier_group_list_result = $.cookie("supplier_group_list_result") === undefined ? "" : $.cookie("supplier_group_list_result");
    let _pageListData = [];
    if (supplier_group_list_result !== "") {
        _pageListData = supplier_group_list_result.split(',');
        $("#rec_total_rows").text(_pageListData.length);
        $("#rec_cur_row").text($.inArray(_dataId, _pageListData) + 1);

        if (_pageListData.length > 0) {
            let index = $.inArray(_dataId, _pageListData);
            if (index === 0) {
                $("#ButPrev").attr("disabled", "disabled");
            } else {
                $("#ButNext").removeAttr("disabled");
            }
            if (index === (_pageListData.length - 1)) {
                $("#ButNext").attr("disabled", "disabled");
            } else {
                $("#ButPrev").removeAttr("disabled");
            }
        }
    } else {
        $("#rec_total_rows").text("1");
        $("#rec_cur_row").text("1");
    }

    _InstancePageHeader = new MyPageHeader(_dataId, 0, 0, _pageStatus, _pageListData,
            "/master/supplier_group/list.html",
            "/master/supplier_group/fetchById.html",
            "/master/supplier_group/save.html",
            "/master/supplier_group/export.html",
            "/master/supplier_group/print.html");

    _InstancePageLinesUser = new MyPageLinesUser();
    _InstancePageLinesSupplier = new MyPageLinesSupplier();

    $("#loading__indicator_01").hide();
    $("#loading__indicator_02").hide();
    $("#tabPanelHeader").wxTabs({tabContent: "tabPanelData"});

    // 设置分页控制 （操作区域）
    $("abbr.page_indicator_block,#wrapper__navbar").attr("_msh_page", 1);
    $("#wrapper__navbar_01").swPagination({
        link_string: '/?page={page_number}',
        max_page: null,
        paged: function (page) {
            $("#page_indicator_block_01").attr("_msh_page", page);
            _InstancePageLinesUser.FetchForPage(page);
        }
    });
    $("#wrapper__navbar_02").swPagination({
        link_string: '/?page={page_number}',
        max_page: null,
        paged: function (page) {
            $("#page_indicator_block_02").attr("_msh_page", page);
            _InstancePageLinesSupplier.FetchForPage(page);
        }
    });

    $("#hPanelSplitter").click(function () {
        if ($(this).children("i").hasClass("fa-angle-double-up")) {
            _InstancePageHeader.Collapse();
        } else {
            _InstancePageHeader.Expand();
        }
    });
    SetSearchWnd();
    _InstancePageHeader.OnPageLoad();
}

// 画面大小或者位置移动
function onPageResize() {
}
// 设置搜索
function SetSearchWnd() {
    $("div.search").unbind('keyup');

    let clazz = 'search--active';
    // 设置对组成员用户进行搜索
    let $search_02 = $('#search_02');
    // 搜索按钮
    $('#search_btn_user').on('click', function (event) {
        $search_02.addClass(clazz);
        $search_02.on(window.transitionProp, function (event) {
            $search_02.find('input').first().focus();
        });
    });
    // 搜索窗口关闭
    $('#search__form_butclose_02').on('click', function (event) {
        $search_02.removeClass(clazz);
    });
    // 搜索框回车直接进行搜索
    $("#search_02").bind('keyup', function (e) {
        let key = e.keyCode;
        if (key === 13) {
            $("#but_filter_02").click();
        }
    });
    // 设置对组成员供应商进行搜索
    let $search_03 = $('#search_03');
    // 搜索按钮
    $('#search_btn_supplier').on('click', function (event) {
        $search_03.addClass(clazz);
        $search_03.on(window.transitionProp, function (event) {
            $search_03.find('input').first().focus();
        });
    });
    // 搜索窗口关闭
    $('#search__form_butclose_03').on('click', function (event) {
        $search_03.removeClass(clazz);
    });
    // 搜索框回车直接进行搜索
    $("#search_03").bind('keyup', function (e) {
        let key = e.keyCode;
        if (key === 13) {
            $("#but_filter_03").click();
        }
    });
}

//-----------------------------------------------------------------------------
// 验证函数
//-----------------------------------------------------------------------------
$.validator.setDefaults({
    ignore: 'hidden, [reaonly=readonly]'
});
$(function () {
    $("#form_data").validate({
        // Step 1：设置验证规则和错误消息
        rules: {
            _GroupNo: "required",
            _GroupName: "required"
        },
        messages: {
            _GroupNo: "请填写供应商组编号。",
            _GroupName: "请填写供应商组名称。"

        },
        // Step 2：设置验证触发事件
        onclick: false,
        onfocusout: false,
        onfocusin: false,
        onkeyup: false,
        onkeydown: false,
        focusInvalid: false,
        // Step 3：设置错误信息提示
        showErrors: window.showErrors  //使用自定义的错误显示方法
    });
});